# -*- coding: utf-8 -*-


"""
模板方法模式
模式特点：定义一个操作中的算法骨架，将一些步骤延迟至子类中。

程序实例：考试时使用同一种考卷（父类），不同学生上交自己填写的试卷（子类方法的实现）

代码特点：无
"""


class TestPaper(object):

    def test_question1(self):
        print "Test1:A. B. C. D."
        print "({})".format(self.answer1())

    def test_question2(self):
        print "Test2:A. B. C. D."
        print "({})".format(self.answer2())

    def answer1(self):
        return ""

    def answer2(self):
        return ""


class TestPaperA(TestPaper):

    def answer1(self):
        return "A"

    def answer2(self):
        return "B"


class TestPaperB(TestPaper):

    def answer1(self):
        return "B"

    def answer2(self):
        return "C"


if __name__ == "__main__":
    s1 = TestPaperA()
    s2 = TestPaperB()
    print "student 1"
    s1.test_question1()
    s1.test_question2()

    print "student 2"
    s2.test_question1()
    s2.test_question2()
